<!DOCTYPE html>
<html class="x-admin-sm">
<head>
    <meta charset="UTF-8">
    <title>操作申请</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="stylesheet" href="./css/font.css">
    <link rel="stylesheet" href="./css/index.css">
    <script src="./lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="./js/index.js"></script>

</head>
<body>
<div class="x-nav">
          <span class="layui-breadcrumb">
            <a href="">首页</a>
            <a href="">BLOGS管理</a>
            <a>
              <cite>操作申请</cite></a>
          </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" onclick="location.reload()" title="刷新">
        <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i></a>
</div>
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body ">
                    <form class="layui-form layui-col-space5">
						<div class="layui-inline layui-show-xs-block">
								<input type="text"  placeholder="请输入操作者姓名" id="adminName"
									autocomplete="off" class="layui-input">
							</div>						
							<div class="layui-inline layui-show-xs-block">
								<button class="layui-btn" lay-submit="" lay-filter="sreach" type="button" onclick="queryArticle()">
									<i class="layui-icon">&#xe615;</i>
								</button>
							</div>
                    </form>
                </div>
               
                <div class="layui-card-body layui-table-body layui-table-main">
                    <table class="layui-table layui-form" id="admin-article">
                        <thead>
                        <tr>
                            <th>
                               编号
                            </th>
                            <th>
                           操作者姓名
                            </th>
                            <th>
                            操作对象Id
                            </th>
                            <th>
              操作后状态
                            </th>
                           
                            <th>
                                操作
                            </th>
                        </tr>
                        </thead>
                        
                        
						<tbody>
						<tr>

						
                           
                        </tr>

                        </tbody>
                    </table>
                </div>
<!-- 分页 -->
               <div class="layui-table-page">
					   	 <div class="layui-table-page1"id="layui-table-page1">
					   		 <div class="layui-box layui-laypage layui-laypage-default" id="layui-laypage-2">
					   		 	
					   		 		</div>
					   		 		</div>
					   		 		</div>
  </div>

            </div>
        </div>
    </div>

</body>
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/jquery.js"></script>
<script>
let pageNum=1;
let pageSize=1;
queryArticle();

/**
 * 文章查询
 */
function queryArticle(){
	//对每页/条数变量进行校验
	//
	pageSize=$("#layui-laypage-2 select").val();

	if(pageSize==null){
		pageSize=2;
	}
	
	
	
	$.ajax({
		async:true,
		type:"post",
		url:"${pageContext.request.contextPath}/OperateRequestSevlt",
		data:{
			op:"query",
			pageNum,
			pageSize,
			adminName:$("#adminName").val()
			
		},
		contentType:"application/x-www-form-urlencoded",
		dataType:"json",
		success:function(result,status,xhr){
			
			let temp = "";
			if(result.list != null){
				
				$.each(result.list,function(index,article){

					temp += "<tr>"+
						"<td>"+(index+1)+"</td>"+						
						"<td>"+result.list[index].adminName+"</td>"+
						"<td>"+result.list[index].operateObjectId+"</td>"+
						"<td>"+result.list[index].operateAfter+"</td>"+
						
						 "<td class=\"td-manage\">"+
			             "<a title=\"编辑\" href=\"javascript:;\" onclick=\"xadmin.open('编辑','operate-request-change.jsp?adminName="+result.list[index].adminName+"&operateObjectId="+result.list[index].operateObjectId+"&operateAfter="+result.list[index].operateAfter+"','800','510','1')\" class=\"ml-5\" style=\"text-decoration:none\">"+
			                  "<i class=\"layui-icon\">&#xe642;</i>"+
			             "</a>"+

			             
			       "</td>"+
					"</tr>";
				
				});
				$("#admin-article tbody").html(temp);
				
				if(result.pageNum==1){
			    	 var tmp=`<span class="layui-laypage-prev layui-disabled" data-page="0"><i class="layui-icon">上一页</i></span>`;
			    }else{
			    	 var tmp=`<a href="javascript:; " class="layui-laypage-prev " data-page="\${result.pageNum-1}"><i class="layui-icon">上一页</i></a>`;
			    }
			    for(let i=1;i<=result.pages;i++){
			    	if(i==result.list[0].pageNum){
			    		tmp+=`<span class="layui-laypage-curr"><em class="layui-laypage-em"></em><em>\${i}</em></span>`;
			    	}else{
			    		tmp+=`<a href="javascript:;" data-page="\${i}">\${i}</a>`;
			    	}
			    }
			    
			    if(result.pageNum==result.pages){
			    	tmp+=`<span class="layui-laypage-next layui-disabled" data-page="\${result.pageNum}"><i class="layui-icon">下一页</i></span>`;
			    }else{
			    	tmp+=`<a href="javascript:;" class="layui-laypage-next" data-page="\${result.pageNum+1}"><i class="layui-icon">下一页</i></a>`;
			    }
			     tmp+=`
		   		 		<span class="layui-laypage-skip">到第
		   		 		<input type="text" min="1" max="\${result.pages}" value="\${result.pageNum}" class="layui-input">页
		   		 		<button type="button" class="layui-laypage-btn">确定</button>
		   		 		</span>
		   		 		<span class="layui-laypage-count">共 \${result.total}条</span>
		   		 		<span class="layui-laypage-limits">
		   		 		<select lay-ignore="">
		   		 		<option value="5">5 条/页</option>
		   		 		<option value="10">10条/页</option>
		   		 		<option value="15">15 条/页</option>
		   		 		</select>
		   		 		</span>`;
			     $("#layui-laypage-2").html(tmp);
			     $("#layui-laypage-2 select option").each(function () {
					if($(this).val()==result.list[0].pageSize){
						$(this).prop("selected","selected");
					}
				})
				}else{
					var tep="查无数据";
					 $("#layui-laypage-2").html(tep);
				};
		    },
		    error:function(xhr,status,error){//请求失败运行的数据
				//result储存服务器响应数据，status服务器响应状态
		    	layer.msg('数据加载失败',{icon:5,time:1000});
		    },
		});
};

$("body").on("click","#layui-laypage-2 a",function(){
	pageNum=$(this).data("page");
	queryArticle( );
});
$("body").on("click","#layui-laypage-2 button",function(){
	let inputPageNum=$("#layui-laypage-2 input").val();
	let maxPage=$("#layui-laypage-2 input").prop("max");
	if(inputPageNum>0&&parseInt(inputPageNum)<=parseInt(maxPage)){
		pageNum=inputPageNum;
		queryArticle();
	}else{
		 layui.use('layer',function(){
			 layer.msg("输入页码只能在1-"+maxPage+"之间",{icon:2,time:3000});
		 });
	}
});
$("body").on("change","#layui-laypage-2 select",function(){
	pageNum=1;

	queryArticle( );
});
function query() {
	 pageNum=1;
	 $(".article").text("没有相关文章");
	 queryArticle( );
}
$("body").on("click","#typequery",function(){
	pageNum=1;
	 $(".article").text("没有相关文章");
	let typeId=$(this).children("input").val();
	queryArticle(typeId);
});

	//读取相应信息
	let message = "${requestScope.msg}"
	if (message != "") {
		//使用layui的layer弹出错误信息
		layui.use('layer', function() {
			layer.msg(message, {
				icon : 1,
				time : 3000
			});
		});
	}  

</script>
</html>